<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>基础数据管理-项目信息新增</title>
    <script src="/scripts/boot.js"></script>
    <link href="/scripts/daterangepicker/js/daterangepicker.min.css" rel="stylesheet" type="text/css" />
    <script src="/scripts/daterangepicker/js/moment.js" type="text/javascript"></script>
    <script src="/scripts/daterangepicker/js/jquery.daterangepicker.min.js" type="text/javascript"></script>
    <script src="/scripts/daterangepicker/ux.daterangepicker.js" type="text/javascript"></script>
    <link href="/scripts/daterangepicker/css/skin.css" rel="stylesheet" type="text/css" />
    <style>
        html body .searchbox .mini-buttonedit-icon
        {
            /*background:url(static/scripts/daterangepicker/search.gif) no-repeat 50% 50%;*/
        }
    </style>
</head>
<body class="bg-white">
<div id="viewForm">
    <div class="title-info mb-20"><span>计划信息</span></div>
    <table class="table-bg" border="0" cellpadding="1" cellspacing="1" style="width:100%;table-layout:fixed;">
        <colgroup>
            <col width="135px"></col>
            <col width="50%"></col>
            <col width="135px"></col>
            <col width="50%"></col>
        </colgroup>
        <tr>
            <td class="text-titlebg">计划类型</td>
            <td>
                <div class="color-66 input-div" id="planTypeName"></div>
                <!--<select id="planType" name="planType" class="mini-combobox w250" ajaxType="post" url="/dictionary/listValues?name=plan_type" textField="value" valueField="id" errorMode="none" onvalidation="onChoseValidation" required="true" requiredErrorText="请选择"></select>-->
            </td>
            <td class="text-titlebg">
                计划名称
            </td>
            <td>
                <div class="color-66 input-div" id="planName"></div>
                <!--<select id="planCombo" name="planId" class="mini-combobox w250" url="/planExe/planList?planTypeId=221" textField="name" valueField="id" required="true"  errorMode="none" onvalidation="onChoseValidation" required="true" requiredErrorText="请选择"></select>-->
            </td>
        </tr>
        <tr>
            <td class="text-titlebg">
                业务板块
            </td>
            <td>
                <div class="color-66 input-div" id="businessName"></div>
                <!--<select id="busiMode" name="busiMode" class="mini-combobox w250" ajaxType="post" url="/dictionary/listValues?name=busi_mode" textField="value" valueField="id" errorMode="none" onvalidation="onChoseValidation" required="true" requiredErrorText="请选择"></select>-->
            </td>
            <td class="text-titlebg">节点名称</td>
            <td>
                <div class="color-66 input-div" id="nodeNames"></div>
                <!--<select id="nodeProperty" name="nodeProperty" class="mini-combobox w250" ajaxType="post" url="/dictionary/listValues?name=nodeProperty" textField="value" valueField="id" errorMode="none" onvalidation="onChoseValidation" required="true" requiredErrorText="请选择"></select>-->
            </td>
        </tr>
        <tr>
            <td class="text-titlebg">
                计划起止时间
            </td>
            <td>
                <div class="color-66 input-div" id="beginDate"></div>
                <!--<input id="date-range1" name="ssDate" class="uc-daterangepicker searchbox w250" />-->
            </td>
            <td class="text-titlebg">
                计划性质
            </td>
            <td>
                <div class="color-66 input-div" id="nodePropertyName"></div>
                <!--<input type="text" name="planNodeName" id="planNodeName" class="mini-textbox w250" required="true" errorMode="none" onvalidation="onNullValidation" requiredErrorText="请输入"　vtype="maxLength:48"/>-->
            </td>
        </tr>
        <tr>
            <td class="text-titlebg">
                进度
            </td>
            <td>
                <div class="color-66 input-div" id="rate"></div>
                <!--<input id="date-range1" name="ssDate" class="uc-daterangepicker searchbox w250" />-->
            </td>
            <td class="text-titlebg">
                计划状态
            </td>
            <td>
                <div class="color-66 input-div" id="state"></div>
                <!--<input type="text" name="planNodeName" id="planNodeName" class="mini-textbox w250" required="true" errorMode="none" onvalidation="onNullValidation" requiredErrorText="请输入"　vtype="maxLength:48"/>-->
            </td>
        </tr>
        <tr>
            <td class="text-titlebg noEmpty">完成标准</td>
            <td colspan="3">
                <div class="color-66 textarea-div" id="completeStandard"></div>
                <!--<textarea name="completeStandard" class="mini-textarea wtextarea" emptyText=""></textarea>-->
            </td>
        </tr>
        <tr>
            <td class="text-titlebg noEmpty">备注</td>
            <td colspan="3" class="wp">
                <div class="color-66 textarea-div" id="remark"></div>
                <!--<textarea name="remark" class="mini-textarea wtextarea" emptyText=""></textarea>-->
                <!--<input name="id" id="planNodeId" class="mini-hidden"/>-->
            </td>
        </tr>
    </table>
    <div class="mini-fit"></div>
    <div class="chose-toolbar">
        <a class="chose-button" onclick="CloseWindow('close')">关闭</a>
    </div>
</div>
<script src="/scripts/res/js/common.js"></script>
<script type="text/javascript">

    var post_flag,form,state,datas;
    var view = {
        init: function () {
            post_flag = false; //设置一个对象来控制是否进入AJAX过程
            mini.parse();
            form = new mini.Form("#viewForm");
        },
        //保存
        save: function () {
            form.validate();
            var data = form.getData();//获取表单多个控件的数据
            if (form.isValid() == false) return;
            if (post_flag) return;

            data['plan.planType.id']=data.planType;
            delete data["planType"];
            data['plan.id']=data.planId;
            delete data["planId"];

            data['nodeName']=data.planNodeName;
            delete data["planNodeName"];

            data['nodeProperty.id']=data.nodeProperty;
            delete data["nodeProperty"];
            data['business.id']=data.busiMode;
            delete data["busiMode"];

            data['postPerson']=data.evaluateId;
            delete data["evaluateId"];
            data['cooperatePostPerson']=data.evaluate;
            delete data["evaluate"];


            data['beginDate']=new Date(data.ssDate.substring(0,10));
            data['endDate']=new Date(data.ssDate.substring(data.ssDate.length-10,data.ssDate.length));

            var deadline=(new Date(data.ssDate.substring(data.ssDate.length-10,data.ssDate.length)).getTime()-new Date(data.ssDate.substring(0,10)).getTime())/(1000*60*60*24);

            data['deadline']=deadline;
            delete data["ssDate"];
            if(data.cooperateDate){
                data['cooperateBeginDate']=new Date(data.cooperateDate.substring(0,10));
                data['cooperateEndDate']=new Date(data.cooperateDate.substring(data.cooperateDate.length-10,data.cooperateDate.length));
                delete data["cooperateDate"];
            }



            post_flag = true;
            $.ajax({
                url: ("/monthlyPlanExecution/save"),
                type: "post",
                data: data,
                success: function (msg) {
                    post_flag = false;
                    common.unmask();
                    CloseWindow("ok");
                },
                error: function (errorMsg) {
                    post_flag = false;
                    common.unmask();
                }
            });
        },
//    数据展示
        SetData: function (data) {
            data = mini.clone(data);
            state = data.state;
            $.ajax({
                url:"/monthlyPlanExecution/info?id=" + data.id,
                type: "post",
                success: function (text) {
                    var obj = JSON.parse(text);
                    //跨页面传递的数据对象，克隆后才可以安全使用
                    datas = mini.decode(obj.body[0]);   //反序列化成对象
                    // form.setData(datas);             //设置多个控件数据
                    var beDate,beDates;
                    $.each(datas,function (key,value) {
                        $("#"+key).html(value);
                        if(key=="beginDate"){
                            beDate=value;
                        }
                        if(key=="endDate"){
                            if(value){
                                beDate=beDate+" ~ "+value;
                            }
                        }
                        if(key=="nodeName"){
                            $("#nodeNames").html(value);
                        }
                        if(key=="rate"){
                        	 $("#rate").html(value+'%');
                        }
                    	 
                        if(key=="state"){
                        	if(value=="1"){
                                $("#state").html('未开始');
                            }else if(value=="2"){
                                $("#state").html('进行中');
                            }else if(value=="3"){
                                $("#state").html('有风险');
                            }else if(value=="4"){
                                $("#state").html('失控');
                            }else if(value=="5"){
                                $("#state").html('已完成');
                            }else if(value=="6"){
                                $("#state").html('延期完成');
                            }
                        }
                        
                        $("#beginDate").text(beDate);
                        $("#cooperateDate").text(beDates);
                    })
                    if(datas.state=="7"){
                    	$("#state").html('逾期'+datas.overDay+"天");
                    }
                }
            });
        }
    };
    view.init();
</script>
</body>
</html>